<?php

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{   
	protected function _initDoctype()
    {
        $this->bootstrap('view');
        $view = $this->getResource('view');
        $view->doctype('XHTML1_STRICT');
        $view->addHelperPath("My/Helper/View","My_Helper_View");
    }
    
    /*
	protected function _initAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => '',
            'basePath'  => APPLICATION_PATH
        ));
        return $autoloader;
    	// Add autoloader empty namespace
        $autoLoader =  new Zend_Loader_Autoloader_Resource(array(
            'basePath'      => APPLICATION_PATH,
            'namespace'     => ''
        ));
        // Return it, so that it can be stored by the bootstrap
        $autoLoader->addResourceType('model', 'models/','');
        $autoLoader->addResourceType('dto', 'models/DTO','DTO');
        $autoLoader->addResourceType('dao', 'models/DAO','DAO');
        return $autoLoader;
    }
    */
    
	protected function _initMyLoad()
    {
		$autoloader = Zend_Loader_Autoloader::getInstance();
		$loader = new My_Loader();
		$autoloader->pushAutoloader($loader);
    	$autoloader->setFallbackAutoloader(true);
    	
		$this->bootstrap('db');
   	 	$this->bootstrap('session');
   	 	$resource = $this->getPluginResource('db');
    	$dbAdapter = $resource->getDbAdapter();
    	Zend_Registry::set("dpAdapter",$dbAdapter);
    	
    }
    
 	/**
     * Setup Helpers
     */
    protected function _initHelper()
    {
        /*
         * Add common controller action helper
         */
    	 Zend_Controller_Action_HelperBroker::addPrefix("My_Helper_Action");

        /*
         * Add common view helper
         */
        Zend_Controller_Action_HelperBroker::addPrefix("My_Helper_View");
    }
    
    protected function _initAuth()
    {
    	$dbAdapter = Zend_Registry::get("dpAdapter");
    	$authAdapter = new Zend_Auth_Adapter_DbTable(
			    $dbAdapter,
			    'user',
			    'userName',
			    'password'
			);
    	Zend_Registry::set("authAdapter",$authAdapter);
    	
    }
    
}

